package com.esm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esm.service.AttendService;
import com.esm.serviceimpl.AttendServiceImpl;
import com.esm.utils.PrintWriterUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * GetSelectDeptYrOtimeController
 * 获取部门年加班记录控制者
 * @author 魏长均
 *
 */
public class GetSelectDeptYrOtimeController_wcj extends HttpServlet
{
	private static final long serialVersionUID = 1L;
	AttendService aService = new AttendServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		String state_zxk = req.getParameter("state_zxk");
		int selectYear = Integer.parseInt(req.getParameter("year"));
		int dep_id = Integer.parseInt(req.getParameter("dep_id"));
		int page = Integer.parseInt(req.getParameter("page"));
		int pageSize = Integer.parseInt(req.getParameter("rows"));
		int total = aService.getSelectDeptYearOtimeTotalRows(state_zxk, selectYear, dep_id);
		JSONArray jao = aService.getSelectDeptYearOTimeLoad(state_zxk, selectYear, dep_id, page, pageSize);
		
		JSONObject  jo = new JSONObject();
		PrintWriter pw = resp.getWriter();
		jo.put("total", total);
		jo.put("rows", jao);
		PrintWriterUtil.flushJoAndClosePrintWriter(pw, jo);
	}
}
